EmaMobile.views.ListeCampagnesView = Ext.extend( Ext.Panel,{

    fullscreen : true,
    layout : {
        type : 'fit',
        align : 'left'
    },

    initComponent : function() {

        this.XmlResponse = null;
        this.responseText;
        
        this.dockedItems = [ {
            dock : 'top',
            xtype : 'toolbar',
            title : '<div class="campagne-image">Liste de Campagnes</div>'
        } ],
        
        this.list = new Ext.List(
            {
                store : 'InfoCampagnesStore',
                itemTpl : '<tpl for="."><div class="Campagne_name"><img src="img/campagne16.png"> {name}</div><div class="Campagne_description">Description : {description}</div><div class="Campagne_date_fin"> Fin : {dateEnd}</div></tpl>',
                scroll : 'vertical',
                onItemDisclosure : true,
                disableSelection : false,
                listeners:{
                    select: function(view, record) {
                             var campagne = record.data.id;
                            //console.log("Id campagne seleccionada: "+campagne);
                            //console.log(EmaMobile.views.authentificationView.urlPlatforme+'/getTodosCampaign?id='+campagne);
                            Ext.Ajax.request({
                                url : EmaMobile.views.authentificationView.urlPlatforme+'/getTodosCampaign?contentType=xml&id='+campagne,
                                scope : this,
                                success : function(response, opts) {

                                    Ext.dispatch({
                                        controller: EmaMobile.controllers.controller,
                                        action: 'list-todo',
                                        content: response.responseText,
                                        direction : 'left'        
                                    });
                                    
                                },
                                failure : function(response, opts) {
                                    
                                    var message = new Ext.MessageBox();
                                    message.show({
                                        title: 'Information',
                                        msg: '<div>Erreur de transmission</div>',
                                        buttons: [{text:'OK',itemId:'ok'}],
                                        fn : function(itemId){
                                        }
                                    });
                                    message.doComponentLayout();   
                                    //console.log("ERROR : "+ response.responseText);
                                        
                                }
                            });
                        
                    }
                }
            }),
                

        this.items = [ this.list ],

        this.list.show();
        
        EmaMobile.views.ListeCampagnesView.superclass.initComponent.call(this);
        
        this.list.show();
    },
});